#include "processBar.h"
#include <unistd.h>
#include <string.h>
const char* waitbar = "|/-\\";
char Bar[NUM] = {0};


void initBar(int rate)
{
    int len = strlen(waitbar);
    printf("[%-100s][%d%%][%c]\r", Bar, rate, waitbar[rate%len]);
    fflush(stdout);
    usleep(50000);
    Bar[rate++] = BODY;
    if (rate < 100)
    {
        Bar[rate] = ARROW;
    }

    if (rate > 100)
    {
        memset(Bar, '\0', sizeof(Bar));
    }
}

//void initBar()
//{
//    char Bar[NUM] = {0};
//    int cnt = 0;
//    int len = strlen(waitbar);
//
//    while (cnt <= 100)
//    {
//        printf("[%-100s][%d%%][%c]\r", Bar, cnt, waitbar[cnt%len]);
//        fflush(stdout);
//        usleep(50000);
//        Bar[cnt++] = BODY;
//        if (cnt < TOP) Bar[cnt] = ARROW;
//    }
//    printf("\n");
//}







